import os
import vision.config as config
import vision.prepare_data.assemble as assemble
import numpy.random as npr


if __name__ == '__main__':

    anno_list = []

    heils_file = '../anno_store/heils-face-annos.txt'
    wider_file = '../anno_store/wider_origin_anno.txt'

    with open(heils_file, 'r') as f:
        heils_annos = f.readlines()
    with open(wider_file, 'r') as f:
        wider_annos = f.readlines()

    imglist_filename = 'wider_heils_anno.txt'
    anno_dir = config.ANNO_STORE_DIR
    imglist_file = os.path.join(anno_dir, imglist_filename)


    with open(imglist_file, "w") as f:

        heils_keep = npr.choice(len(heils_annos),  size=len(heils_annos), replace=False)
        wider_keep = npr.choice(len(wider_annos), size=len(wider_annos), replace=False)

        print('heils num:{},choice:{}'.format(len(heils_annos), len(heils_keep)))
        print('wider num:{},choice:{}'.format(len(wider_annos), len(wider_keep)))

        for i in heils_keep:
            f.write(heils_annos[i])
        for i in wider_keep:
            f.write(wider_annos[i])


    # chose_count = assemble.assemble_data(imglist_file ,anno_list)
    print("Train annotation result file path:%s" % imglist_file)

    chose_count = assemble.assemble_data(imglist_file ,anno_list)
    print("Concat heils-face-annos.txt with wider_origin_anno.txt:%s" % imglist_file)